
import excel using "../2_Data/raw/mountains_data.xls", firstrow clear

rename (Montanit PROVINCIA) (mount_surface2005 province)

collapse (sum) mount_surface2005, by(province)

replace province = strupper(province)

replace province=strtrim(province)

replace province="AOSTA" if strpos(province,"AOSTA")!=0
replace province="BOLZANO" if strpos(province,"BOLZANO")!=0
replace province="FORLI'-CESENA" if strpos(province,"CESENA")!=0
replace province="MASSA CARRARA" if strpos(province,"CARRARA")!=0
replace province="PESARO E URBINO" if province=="PESARO - URBINO"
replace province="MASSA CARRARA" if province=="MASSA"
replace province="FORLI'-CESENA" if strpos(province,"FORL")!=0
replace province="VERBANO-CUSIO-OSSOLA" if strpos(province,"VERBAN")!=0


*Retrieve data from South Sardinia


preserve

keep if strpos(province,"CARBONIA") | strpos(province,"MEDIO")

gen id="a"

collapse (sum) mount_surface2005, by(id)

rename id province

replace province = "SUD SARDEGNA"

tempfile sud
save `sud', replace

restore

append using `sud'

tempfile mount_surface
save `mount_surface', replace

import excel using "../2_Data/raw/st_diff_data.xlsx", firstrow clear allstring

rename Provincia province

replace province = strupper(province)

replace province=strtrim(province)

replace province="AOSTA" if strpos(province,"AOSTA")!=0
replace province="BOLZANO" if strpos(province,"BOLZANO")!=0
replace province="FORLI'-CESENA" if strpos(province,"CESENA")!=0
replace province="MASSA CARRARA" if strpos(province,"CARRARA")!=0
replace province="PESARO E URBINO" if province=="PESARO - URBINO"
replace province="MASSA CARRARA" if province=="MASSA"
replace province="FORLI'-CESENA" if strpos(province,"FORL")!=0
replace province="VERBANO-CUSIO-OSSOLA" if strpos(province,"VERBAN")!=0

foreach var of varlist * {
replace `var'="" if `var'=="-"
replace `var' = "0" if `var'==""
replace `var'="" if `var'==".."| `var'=="...."
destring `var', replace
}


merge 1:1 province using `mount_surface', assert(match) nogen


save "../2_Data/temp/data_std_diff.dta", replace
